<?php
class oauth_api_token {
	
	private $_data = array();
	public function __construct($data = array()) {
		$this->_data = $data;
	}
	
	public function getAccessToken() {
		return $this->get('access_token');
	}
	
	public function getAppId() {
		return $this->get('app_id');
	}
	
	public function getAppKey() {
		return $this->get('app_key');
	}
	
	public function getExpires() {
		return $this->get('expires', 0);
	}
	
	public function toArray() {
		return $this->_data;
	}
	
	public function get($index, $default = null) {
		if(isset($this->_data[$index])) {
			return $this->_data[$index];
		}
		return null;
	}
	
	public function __call($method, array $args) {
		if(preg_match('/^get(\w+?)$/', $method, $matches)) {
			$index = strtolower($matches[1]);
			$default = isset($args[0]) ? $args[0] : null;
			return $this->get($index, $default);
		}
		return null;
	}

}
